package com.sunshine.wrongquestionset.room.entity

import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey

/**
 * @author sunshine
 * @date 2021/3/26
 * 科目实体类
 */
@Entity(
    tableName = "subject",
    foreignKeys = [
        ForeignKey(
            entity = UserEntity::class,
            parentColumns = ["id"],
            childColumns = ["userId"],
            onDelete = ForeignKey.CASCADE,
            onUpdate = ForeignKey.CASCADE
        )
    ],
    indices = [
        Index("userId")
    ]
)
class SubjectEntity(
    @PrimaryKey(autoGenerate = true)
    val id: Int,
    val userId: String,
    var name: String
) {
    override fun toString(): String {
        return "SubjectEntity(id=$id, name='$name')"
    }
}